<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@include file="/ui/jsp/includes/header.jspf"%>

<script src="<%=request.getContextPath()%>/ui/js/jquery.js"></script>
<%-- <script src="<%=request.getContextPath()%>/ui/js/paginate.js"></script> --%>
<%-- <script src="<%=request.getContextPath()%>/ui/js/customPaginate.js"></script> --%>
<script src="<%=request.getContextPath()%>/ui/js/jquery.dataTables.min.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/customDataTables.js"></script>

<script type="text/javascript">
	function viewFacultyResearch(facultyResearchId) {
		$('#facultyResearchId').val(facultyResearchId);
		$('#viewFacultyResearchForm').attr('action', 'viewExistingFacultyResearch.html');
		$('#viewFacultyResearchForm').submit();
	}
	function addNewFacultyResearch() {
		$('#viewFacultyResearchForm').attr('action', 'viewNewFacultyResearch.html');
		$('#viewFacultyResearchForm').submit();
	}
	function viewFacultyResearchDetails(facultyResearchId) {
		$('#facultyResearchId').val(facultyResearchId);
		$('#viewFacultyResearchForm').attr('action', 'viewFacultyResearchDetails.html');
		$('#viewFacultyResearchForm').submit();
	}
	function printFacultyResearchList(){
		window.open('printFacultyResearchList.html');
	}
</script>

<div class="hero-unit secondary_container">
    <div id="table-subject-header">
        View Faculty Research List
    </div>
        <hr>

    <div class="row-fluid">
    <form method="POST" id="viewFacultyResearchForm">
                <c:if test="${loggedInUser==true && roleId==1 || roleId==2 || roleId==3}">
                    <div class="addnew_button">
						<input type="button" title="Add New Faculty Research" value="Add New" onclick="javascript:addNewFacultyResearch()" class="btn btn-primary">
						<input type="button" title="Display in a Print-friendly Format" value="Print" onclick="javascript:printFacultyResearchList()" class="btn btn-primary">
					</div>
                </c:if>
                <div class="span10">

            <table id='dataTableList' class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th width="8%">Action</th>
                        <th>Research Title</th>
				<!--    <th>Faculty Member</th> 		-->
						<th>Faculty First</th>
						<th>Faculty Last</th>
                        <th>Category</th>
                        <th>Research URL</th>
                        <th style="display:none;">Description</th>
                        <th>Status</th>
                    </tr>
                </thead>
                <tbody>

                    <c:forEach var="facultyResearch" items="${facultyResearchList}">
                        <tr class="paginationList">
                        	<td>
                        		<a href="javascript:viewFacultyResearchDetails('${facultyResearch.facultyResearchId}')"><img src="<%=request.getContextPath()%>/ui/images/view.gif" title="View"/></a>
                        		<c:if test="${roleId==1 || roleId==2 || roleId==3}">
                            		<a href="javascript:viewFacultyResearch('${facultyResearch.facultyResearchId}')"><img src="<%=request.getContextPath()%>/ui/images/edit.gif" title="Edit"/></a>
                            	</c:if>
                            <!-- 	<c:if test="${roleId==1}">
                            		<a href=""><img src="<%=request.getContextPath()%>/ui/images/delete.gif" title="Delete"/></a>
                            	</c:if> -->
                            </td>

                            <td>${facultyResearch.title}</td>
                	<%-- 	<td>${facultyResearch.faculty.firstName}&nbsp;${facultyResearch.faculty.lastName}</td> 		--%>
							<td>${facultyResearch.faculty.firstName}</td>
							<td>${facultyResearch.faculty.lastName}</td>
                            <td>${facultyResearch.category.categoryName}</td>
                            <td><a href="${facultyResearch.researchUrl}" target="_blank">${facultyResearch.researchUrl}</a></td>
                            <td style="display:none;">${facultyResearch.description}</td>
                            <td>${facultyResearch.status}</td>
                        </tr>
                    </c:forEach>
                </tbody>

            </table>
            
            <div class="pagination">
            </div>
            
        </div>
        <input type="hidden" id="facultyResearchId" name="facultyResearchId" value=""/>
		</form>
    </div>
</div>

<%@include file="/ui/jsp/includes/footer.jspf"%>
